package cn.com.ccxe.web.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

import com.ccxe.manage.service.CurrUserInfo;

public class WebsiteActionForm extends ActionForm {

	private int 			id;
	private int 			moduleId;
	private int 			parentId;
	private int 			keywordId;
	private short 			isList;
	private short 			isMonitor;
	private String 			name;
	private String 			discription;
	private String 			path;
	private String 			method;
	private CurrUserInfo 	userInfo;
	private String[] 		keywords;
	private String			articleListExpre;
	private String			listPageExpre;
	private String			datePattern;
	private String			dateExpre;
	
	

	public WebsiteActionForm(HttpServletRequest request) {
		super(request);
	}

	@Override
	protected void reset() {
		String str_id = getParemetes("id");
		if (isEmpty(str_id)) {
			this.id = Integer.parseInt(str_id);
		}
		String str_keywordId = getParemetes("keywordId");
		if (isEmpty(str_keywordId)) {
			this.keywordId = Integer.parseInt(str_keywordId);
		}
		String str_moduleId = getParemetes("moduleId");
		if (isEmpty(str_moduleId)) {
			this.moduleId = Integer.parseInt(str_moduleId);
		}
		String str_parentId = getParemetes("parentId");
		if (isEmpty(str_parentId)) {
			this.parentId = Integer.parseInt(str_parentId);
		}
		
		String str_isMonitor = getParemetes("isMonitor");
		if(isEmpty(str_isMonitor)) {
			this.isMonitor = Short.parseShort(str_isMonitor);
		}
		String str_isList = getParemetes("isList");
		if(isEmpty(str_isList)) {
			this.isList = Short.parseShort(str_isList);
		}
		keywords = getParameterValues("keywords");
		
		this.discription = getParemetes("discription");
		this.path = getParemetes("path");
		this.name = getParemetes("name");
		this.method = getParemetes("method");
		this.userInfo = (CurrUserInfo) getAttribute("currUser");
		this.articleListExpre = getParemetes("articleListExpre");
		this.listPageExpre = getParemetes("listPageExpre");
		this.datePattern = getParemetes("datePattern");
		this.dateExpre = getParemetes("dateExpre");
	}
	
	private boolean isEmpty(String str) {
		return !StringUtils.isEmpty(str);
	}

	public void clearMethod(){this.method="";}
	public int getId() {return id;}
	public int getKeywordId() {return keywordId;}
	public int getParentId() {return parentId;}
	public int getModuleId() {return moduleId;}
	public short getIsList() {return isList;}
	public short getIsMonitor() {return isMonitor;}
	public String getMethod() {return method;}
	public String getName() {return name;}
	public String getPath() {return path;}
	public String getDiscription() {return discription;}
	public String[] getKeywords() {return keywords;}
	public CurrUserInfo getUserInfo() {return userInfo;}
	public String getArticleListExpre() {return articleListExpre;}
	public String getListPageExpre() {	return listPageExpre;}
	public String getDatePattern() { return datePattern;}
	public String getDateExpre() { return dateExpre; }
	
}